def resource_to_create(module):
    instance = resource_to_request(module)
    instance['name'] = "projects/{0}/instances/{1}".format(module.params['project'],
                                                           module.params['name'])
    instance['config'] = "projects/{0}/instanceConfigs/{1}".format(module.params['project'],
                                                                   instance['config'])
    return {
        'instanceId': module.params['name'],
        'instance': instance
    }


def resource_to_update(module):
    instance = resource_to_request(module)
    instance['name'] = "projects/{0}/instances/{1}".format(module.params['project'],
                                                           module.params['name'])
    instance['config'] = "projects/{0}/instanceConfigs/{1}".format(module.params['project'],
                                                                   instance['config'])
    return {
        'instance': instance,
<% fields = object.properties.select { |p| !p.output }.map(&:name) -%>
        'fieldMask': "<%= fields.map { |x| quote_string(x) }.join(' ,') -%>"
    }


def decode_response(response, module):
    if not response:
        return response

    if '/operations/' in response['name']:
        return response

    response['name'] = response['name'].split('/')[-1]
    response['config'] = response['config'].split('/')[-1]
    return response
